package com.ngovanhau.justsort.adapter;

import com.ngovanhau.justsort.R;
import com.ngovanhau.justsort.model.Level;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class LevelNoRow implements Row {
	private final Level level;
	private final LayoutInflater inflater;

	public LevelNoRow(LayoutInflater inflater, Level level) {
		this.level = level;
		this.inflater = inflater;
	}

	public View getView(View convertView, ViewGroup group) {
		ViewHolder holder;
		View view;
		
		if (convertView == null) {
			ViewGroup viewGroup = (ViewGroup) inflater.inflate(
					R.layout.listview_item_level_item_no, group, false);

			holder = new ViewHolder(
					(TextView) viewGroup.findViewById(R.id.lv_item_no_size));
			viewGroup.setTag(holder);

			view = viewGroup;
		} else {
			holder = (ViewHolder) convertView.getTag();
			view = convertView;
		}

		holder.sizeView.setText(level.getRow() + "x" + level.getColumn());

		return view;
	}

	public int getViewType() {
		return RowType.ITEM_NO.ordinal();
	}

	private static class ViewHolder {
		final TextView sizeView;

		private ViewHolder(TextView sizeView) {
			this.sizeView = sizeView;
		}
	}
}
